<section class="sidebar-content">
	<aside class="sidebar-primary">
		
		<section class="block bordered-block">

			<h2 class="block-title">Find your friends now.</h2>

			<div class="block-content">

				<div style="padding: 0 15px;" id="find_friends">
					<?php $form = $this->beginWidget('CActiveForm', array(
						'id' => 'find-friends-form',
						'action' => $this->createUrl('/user/findFriends'),
						'enableClientValidation' => false,
						'clientOptions' => array(
							'validateOnSubmit' => true,
						),
						'htmlOptions' => array(
							'class' => 'cm-ajax find-friends',
						),
					)); ?>

					<input type="hidden" name="result_ids" value="find_friends,find_friend_results" />

					<div class="form-field row">
						<?php echo $form->labelEx($model, 'name'); ?>
						<?php echo $form->textField($model, 'name', array('class' => 'input-text', 'placeholder' => 'Name')); ?>
						<?php echo $form->error($model, 'name'); ?>
					</div>

					<div class="form-field row">
						<?php echo $form->labelEx($model, 'email'); ?>
						<?php echo $form->textField($model, 'email', array('class' => 'input-text', 'placeholder' => $model->getAttributeLabel('email'))); ?>
						<?php echo $form->error($model, 'email'); ?>
					</div>

<!--					<div class="form-field row">
						<?php echo $form->labelEx($model, 'love_category'); ?>
						<?php echo $form->textField($model, 'love_category', array('class' => 'input-text', 'placeholder' => $model->getAttributeLabel('love_category'))); ?>
						<?php echo $form->error($model, 'love_category'); ?>
					</div>

					<div class="form-field row">
						<?php echo $form->labelEx($model, 'love_author'); ?>
						<?php echo $form->textField($model, 'love_author', array('class' => 'input-text', 'placeholder' => $model->getAttributeLabel('love_author'))); ?>
						<?php echo $form->error($model, 'love_author'); ?>
					</div>-->

					<div class="text-left">
						<?php echo CHtml::submitButton('Search', array('class' => 'button button2')); ?>
						<br /><br />
					</div>

					<?php $this->endWidget(); ?>

				<!--find_friends--></div>
			</div>

		</section>
		
		
	</aside><!-- sidebar -->
	
	<main class="content">
		
		<section class="block">

			<h2 class="block-title">You may know them...</h2>

			<div class="block-content" id="find_friend_results">

				<?php if ( !empty($suggested_friends) ) {

					printf('<div class="find-friends-results">');
					foreach ($suggested_friends as $u) {

						$user = User::model()->with('avatar')->findByPk($u['user_id']);

						if ( empty($user) ) continue;

						printf('<div class="user-info result clearfix">');

						printf('<a class="thumbnail" href="%s">', $user->profileUrl);
						$this->renderPartial('//common/image', array('pair' => $user->avatar, 'object_type' => 'user', 'width' => 80, 'height' => 80));
						printf('</a>');

						printf('<a class="name" href="%s">%s</a>', $user->profileUrl, userDisplayName($user));

						if ( !empty($u['mutual_friends_count']) ) {
							$mutual_friends = array_unique(explode(',', $u['mutual_friends']));
							
							$mutual_friend_seo_names = array_unique(explode(',', $u['mutual_friend_seo_names']));
							$max = 2; $count = 0;
							$mutual_friend_links = array();
							foreach ((array)$mutual_friends as $k => $f) {

								if ( $count >= $max ) break;

								$mutual_friend_links[] = sprintf('<a href="%s">%s</a>', $this->createUrl('/user/view', array('name' => $mutual_friend_seo_names[$k])), $f);

								$count++;

							}
							
							if ( !empty($mutual_friend_links) ) {
								printf('<div style="font-size: 90%%;">%s is your friend</div>', implode(' và ', $mutual_friend_links));
							}
						}

						printf('<div class="buttons">');
						if ( $user->requestedFriend(user()->id) ) {
							printf('<a class="friend friend-requested">Already sent invitation</a>');
						} elseif ( $user->isFriend(user()->id) ) {
							printf('<a class="friend friended">Đã kết bạn</a>');
						} else {
							printf('<a rel="nofollow" href="%s" name="friend" class="cm-ajax friend add-friend"><i class="icon-friend">+</i> Invite</a>', $user->friendUrl);
						}
						printf('</div>');

						printf('</div>');

					}
					printf('</div>');
					
				} else {
					printf('<p><em>%s</em></p>', t('No record found !!!!'));
				} ?>

				<!--find_friend_results--></div>

		</section>

	</main><!-- content -->
</section>